"use strict";

(function () {
  function r(e, n, t) {
    function o(i, f) {
      if (!n[i]) {
        if (!e[i]) {
          var c = "function" == typeof require && require;
          if (!f && c) return c(i, !0);
          if (u) return u(i, !0);
          var a = new Error("Cannot find module '" + i + "'");
          throw a.code = "MODULE_NOT_FOUND", a;
        }

        var p = n[i] = {
          exports: {}
        };
        e[i][0].call(p.exports, function (r) {
          var n = e[i][1][r];
          return o(n || r);
        }, p, p.exports, r, e, n, t);
      }

      return n[i].exports;
    }

    for (var u = "function" == typeof require && require, i = 0; i < t.length; i++) {
      o(t[i]);
    }

    return o;
  }

  return r;
})()({
  1: [function (require, module, exports) {
    "use strict";

    loader.define({
      depend: ["pages/config/config"],
      loaded: function loaded(o, t, e, a, n) {
        return this.pageview = {
          init: function init(t) {
            var s, i, a, n, c;
            bui.getPageParams().done(function (t) {
              s = t.id, i = t.type, a = t.lng, n = t.lat;
              var e = {
                id: s
              };
              e = JSON.stringify(e), bui.ajax({
                url: o.apiurl + "api/v1.0/actdetails",
                data: e,
                method: "post",
                headers: {
                  "Content-Type": "application/json"
                }
              }).then(function (t) {
                console.log(t), c = t.uid;
                var e = t.is_involve_star ? "images/other/star2.png" : "images/other/star1.png";
                $("#btn-collect .icon-collect img").attr("src", e), $("#actype").text(i), $("#acname").text(t.name), $("#accontent").text(t.content), $("#actime").text(t.time), $("#acaddress").text(t.address), $("#acfee").text(t.cost);
                var a = Number(t.peoplecount),
                    n = Number(t.peoplesurplus);
                $("#acnum").text(String(a - n) + "/" + String(a)), t.is_involved ? ($("#btn_attend").addClass("btn-disable"), $("#btn_attend").text("你已报名")) : n <= 0 ? ($("#btn_attend").addClass("btn-disable"), $("#btn_attend").text("人数已满，无法报名")) : ($("#btn_attend").addClass("btn-able"), $("#btn_attend").text("报名参加"));
              }, function (t, e) {
                console.log(e);
              });
            }), $("#btn-collect2").on("click", function (t) {
              var e,
                  a,
                  n = $("#btn-collect .icon-collect img").attr("src");
              e = "images/other/star1.png" == n ? (n = "images/other/star2.png", a = "addstaract", 1) : (n = "images/other/star1.png", a = "delstaract", 0), console.log(s);
              var i = {
                id: s
              };
              i = JSON.stringify(i), bui.ajax({
                url: o.apiurl + "api/v1.0/" + a,
                data: i,
                method: "post",
                headers: {
                  "Content-Type": "application/json"
                }
              }).then(function (t) {
                console.log(t), $("#btn-collect .icon-collect img").attr("src", n), 1 == e && bui.hint({
                  content: "<i class='icon-check'></i><br />收藏成功",
                  position: "center",
                  effect: "fadeInDown"
                });
                0 == e && bui.hint({
                  content: "<i class='icon-check'></i><br />取消收藏",
                  position: "center",
                  effect: "fadeInDown"
                });
              });
            }), $("#btn_attend").on("click", function (t) {
              if ($(this).hasClass("btn-able")) {
                console.log(s);
                var e = {
                  id: s
                };
                e = JSON.stringify(e), bui.ajax({
                  url: o.apiurl + "api/v1.0/actinvolve",
                  data: e,
                  method: "post",
                  headers: {
                    "Content-Type": "application/json"
                  }
                }).then(function (t) {
                  console.log(t), location.reload();
                });
              }
            });
            bui.actionsheet({
              trigger: "#btn_shared",
              appendTo: "#activitydetail",
              buttons: [{
                name: "微信好友分享",
                value: "session"
              }, {
                name: "微信好友圈分享",
                value: "timeline"
              }],
              callback: function callback(t) {
                switch ($(t.target).attr("value")) {
                  case "session":
                    shareHref(s, $("#acname").text(), $("#accontent").text(), $("#actime").text(), $("#acaddress").text(), $("#acfee").text(), $("#acnum").text(), "session"), this.hide();
                    break;

                  case "timeline":
                    shareHref(s, $("#acname").text(), $("#accontent").text(), $("#actime").text(), $("#acaddress").text(), $("#acfee").text(), $("#acnum").text(), "timeline"), this.hide();
                    break;

                  case "cancel":
                    ui.hide();
                }
              }
            });
            $("#addressmap").on("click", function (t) {
              bui.load({
                url: "pages/addressmap/addressmap",
                param: {
                  lng: a,
                  lat: n,
                  address: $("#acaddress").text(),
                  uid: c
                }
              });
            });
          }
        }, this.pageview.refresh = function () {
          location.reload();
        }, this.pageview.init(), this.pageview;
      }
    });
  }, {}]
}, {}, [1]);